package top.hekun.study.core.model;

import java.util.Random;

/**
 * 〈classfile 文件结构学习类〉
 *
 * @author: Sakura
 * @date: 2023/4/24
 */
public class HelloWord implements Cloneable {

    private static final int intValue = 10;
    public int newIntValue = 20;
//    @MyAnnotation(name = "这是姓名", age = 1)
    private static final String name = "kk";

    static {
        System.out.println(intValue);
        System.out.println("你好!!");
    }

    public void test0() {
        System.out.println(newIntValue);
        int a = 99;
        int b = 77;
        int c = a + b;
        System.out.println(this);
        System.out.println(c);
    }

    public void test1(int a, int b) {
        System.out.println("方法参数: " + a);
        int max = Math.max(a, b);
        System.out.println(max);
    }

    public void test2(int a, int b) {
        if (a > b) {
            System.out.println(a);
        } else {
            System.out.println(b);
        }
        return;
    }

    public void test3(int a) {
        switch (a) {
            case -1:
                System.out.println("数值是 -1 ");
                break;
            case 0:
                System.out.println("数值是 0 ");
                break;
            case 1:
                System.out.println("数值是 1 ");
                break;
            case 2:
                System.out.println("数值是 2 ");
                break;
            case 3:
                System.out.println("数值是 3 ");
                break;
            case 4:
                System.out.println("数值是 4 ");
                break;
            case 5:
                System.out.println("数值是 5 ");
                break;
            default:
                System.out.println("数值是 其他 ");
        }
    }

    public void test4(int a) {
        switch (a) {
            case -10:
                System.out.println("数值是 -10 ");
                break;
            case 0:
                System.out.println("数值是 0 ");
                break;
            case 10:
                System.out.println("数值是 10 ");
                break;
            case 20:
                System.out.println("数值是 20 ");
                break;
            case 30:
                System.out.println("数值是 30 ");
                break;
            case 40:
                System.out.println("数值是 40 ");
                break;
            case 50:
                System.out.println("数值是 50 ");
                break;
            default:
                System.out.println("数值是 其他 ");
        }
    }

    public void test4(String a) {
        switch (a) {
            case "-10":
                System.out.println("数值是 -10 ");
                break;
            case "0":
                System.out.println("数值是 0 ");
                break;
            case "10":
                System.out.println("数值是 10 ");
                break;
            case "20":
                System.out.println("数值是 20 ");
                break;
            case "30":
                System.out.println("数值是 30 ");
                break;
            case "40":
                System.out.println("数值是 40 ");
                break;
            case "50":
                System.out.println("数值是 50 ");
                break;
            default:
                System.out.println("数值是 其他 ");
        }
    }

    public void test5() {
        try {
            System.out.println("开始");
            Thread.sleep(5000L);
            System.out.println("开始");
        } catch (InterruptedException e) {
            e.printStackTrace();
            System.out.println("InterruptedException");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public double test6(int a, int b) throws InterruptedException {
        double d = a + b;
        Random random = new Random();
        Thread.sleep(random.nextInt(500));
        return d;
    }

    public double test7(int a, int b) throws InterruptedException {
        long start = System.currentTimeMillis();
        double d = a + b;
        return d;
    }

    public boolean authentication(String requestURI) throws Exception {

        return true;
    }

}
